package generic_function

import "fmt"

func GuessType[T interface{ int | string }](ele ...T) T {
	var s T
	for _, v := range ele {
		s += v
	}
	return s
}

func GuessType2[K int | string, V int | string](k K, v V) {
	fmt.Println("GuessType2:K:", k)
	fmt.Println("GuessType2:V:", v)
}

// 表示V按K的标准走
func GuessType3[K int | string, V []K](k K, v V) {
	fmt.Println("GuessType3:K:", k)
	fmt.Println("GuessType3:V:", v)
}

func GenericFunc() {
	fmt.Println(GuessType(1, 2, 3))
	fmt.Println(GuessType[int](1, 2, 3))

	fmt.Println(GuessType("liao", "jian"))
}
func GenericFunc2() {
	GuessType2(123, "woshizhu")
	GuessType3(123, []int{1, 2, 3})
}
